﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using InspectionMAC.Algorithm;
using InspectionMAC.Forms;

namespace InspectionMAC.SystemThread
{
    class AlgorithmThread
    {
        // 启动算法线程
        public static bool Algorithm_Flowrec = false;
        public static Thread Algorithm_Thread = null;
        public static int iAlgorithm_Step = 0;

        public static bool Algorithm_Stop = false;
        public static void AlgorithmThreadInit()
        {
            Algorithm_Flowrec = true;
            Algorithm_Thread = new Thread(AlgorithmFlowThread);
            Algorithm_Thread.IsBackground = true;
            Algorithm_Thread.Start();
        }

        private static void AlgorithmFlowThread(object obj)
        {
            while (Algorithm_Flowrec)
            {
                switch (iAlgorithm_Step)
                {
                    case 10:
                        string imagePath = @"Test\9.jpg";
                            try
                            {
                                // 调用算法处理图像
                            AlgorithmModule.ImageHandleBitmap1(imagePath);
                           
                            Thread.Sleep(10000);
                            }
                            catch (Exception ex)
                            {
                                MacTestForm.macTestForm.AddLog($"算法线程错误: {ex.Message}");
                                break;
                            }
                        iAlgorithm_Step = 45;
                        break;
                    case 45:
                        Thread.Sleep(100);
                        break;

                    
                }
            }
        }
    }
}
